package de.tum.in.eist.poll.client;

//package com.googlecode.gchart.gcharttestapp.client;

import com.googlecode.gchart.client.GChart;

/**
 * Basic pie chart
 * <p>
 * 
 * This chart uses the built-in HTML-element based pie chart rendering. As of
 * GChart 2.5, faster drawn, better looking, solid-filled pie slices can be
 * produced by plugging an external canvas library into GChart. See the
 * <tt>setCanvasFactory</tt> method's javadocs for the details, and the various
 * pie charts on GChart's live demo for complete working examples.
 * 
 */
public class Chart extends GChart {
	Chart(double veryUnsatisfied, double unsatisfied, double neutral, double satisfied, double verySatisfied) {
		double[] pieMarketShare = {veryUnsatisfied, unsatisfied, neutral, satisfied, verySatisfied};
		String[] pieTypes = { "Very Unsatisfied", "Unsatisfied", "Neutral",
				"Satisfied", "Very Satisfied" };
		String[] pieColors = { "green", "red", "maroon", "yellow", "blue" };

		this.setChartSize(300, 200);
		setChartTitle("<h3>overall rating" + "<br>(Lecture number) </h3>");
		this.setLegendVisible(false);
		getXAxis().setAxisVisible(false);
		getYAxis().setAxisVisible(false);
		getXAxis().setAxisMin(0);
		getXAxis().setAxisMax(10);
		getXAxis().setTickCount(0);
		getYAxis().setAxisMin(0);
		getYAxis().setAxisMax(10);
		getYAxis().setTickCount(0);
		// this line orients the center of the first slice (apple) due east
		setInitialPieSliceOrientation(0.75 - pieMarketShare[0] / 2);
		for (int i = 0; i < pieMarketShare.length; i++) {
			addCurve();
			getCurve().addPoint(5, 5);
			getCurve().getSymbol().setSymbolType(
					SymbolType.PIE_SLICE_OPTIMAL_SHADING);
			getCurve().getSymbol().setBorderColor("white");
			getCurve().getSymbol().setBackgroundColor(pieColors[i]);
			// next two lines define pie diameter in x-axis model units
			getCurve().getSymbol().setModelWidth(6);
			getCurve().getSymbol().setHeight(0);
			getCurve().getSymbol().setFillSpacing(3);
			getCurve().getSymbol().setFillThickness(3);
			getCurve().getSymbol().setHovertextTemplate(
					GChart.formatAsHovertext(pieTypes[i] + ", "
							+ Math.round(100 * pieMarketShare[i]) + "%"));
			getCurve().getSymbol().setPieSliceSize(pieMarketShare[i]);
			getCurve().getPoint().setAnnotationText(pieTypes[i]);
			getCurve().getPoint().setAnnotationLocation(
					AnnotationLocation.OUTSIDE_PIE_ARC);
		}
	}

}
